/* processing short and long cmdline options */

#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main (int argc, char **argv)
{
	short recursive=0, quiet=0, verbose=0, debug=0;
	short i=1, j=1;
	while (i<argc) {
		if (argv[i][0] == '-') {
			if (argv[i][1] == '-') {
				if (!strcmp(argv[i],"--recursive")) {
					recursive=1;
					printf("recursive (l)\n");
				} else if (!strcmp(argv[i],"--quiet")) {
					quiet=1;
					printf("quiet (l)\n");
				} else if (!strcmp(argv[i],"--verbose")) {
					verbose=1;
					printf("verbose (l)\n");
				} else if (!strcmp(argv[i],"--debug")) {
					debug=1;
					printf("debug (l)\n");
				} else {
					fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], argv[i]);
				}
			} else {
				for (j=1 ; j<strlen(argv[i]) ; j++) {
					switch (argv[i][j]) {
					case 'r':
						recursive=1;
						printf("recursive\n");
						break;
					case 'q':
						quiet=1;
						printf("quiet\n");
						break;
					case 'v':
						verbose=1;
						printf("verbose\n");
						break;
					case 'd':
						debug=1;
						printf("debug\n");
						break;
					default:
						fprintf(stderr, "%s: unrecognized option '%c'\n", argv[0], argv[i][j]);
					}
				}
			}
		}
		i++;
	}
	printf("UHHHH there we go\n");
	//fprintf(stderr, "(i+1):%s  (i):%s  (i-1):%s\n", argv[i+1], argv[i], argv[i-1]);
	return 0;
}
